from collections import defaultdict

def get_syn_dict():
    syn_dict = defaultdict(set)
    with open(r'G:\syn\哈工大社会计算与信息检索研究中心同义词词林扩展版\哈工大社会计算与信息检索研究中心同义词词林扩展版.txt') as fin:
        for line in fin:
            sp = line.split()
            if sp[0].endswith('='):
                sp = sp[1:]
                for i in range(0, len(sp)):
                    for j in range(i+1, len(sp)):
                        syn_dict[sp[i]].add(sp[j])
                        syn_dict[sp[j]].add(sp[i])
    return syn_dict


SYN_DICT = get_syn_dict()

